package com.kitty.web.controller;

import com.kitty.web.controller.BaseController;
import com.kitty.web.common.AjaxResult;
import com.kitty.web.core.page.TableDataInfo;
import com.kitty.web.domain.POnlinemall;
import com.kitty.web.system.onlinemall.service.IPOnlinemallService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * 元宝商城Controller
 * 
 * @author soul
 * @date 2022-03-10
 */
@Controller
@RequestMapping("/system/onlinemall")
public class POnlinemallController extends BaseController
{
    private String prefix = "system/onlinemall";

    @Autowired
    private IPOnlinemallService pOnlinemallService;


    @GetMapping()
    public String onlinemall()
    {
        return prefix + "/onlinemall";
    }

    /**
     * 查询元宝商城列表
     */

    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(POnlinemall pOnlinemall)
    {
        startPage();
        List<POnlinemall> list = pOnlinemallService.selectPOnlinemallList(pOnlinemall);
        return getDataTable(list);
    }

    /**
     * 新增元宝商城
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存元宝商城
     */

    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(POnlinemall pOnlinemall)
    {
        return toAjax(pOnlinemallService.insertPOnlinemall(pOnlinemall));
    }

    /**
     * 修改元宝商城
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        POnlinemall pOnlinemall = pOnlinemallService.selectPOnlinemallById(id);
        mmap.put("pOnlinemall", pOnlinemall);
        return prefix + "/edit";
    }

    /**
     * 修改保存元宝商城
     */

    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(POnlinemall pOnlinemall)
    {
        return toAjax(pOnlinemallService.updatePOnlinemall(pOnlinemall));
    }

    /**
     * 删除元宝商城
     */

    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(pOnlinemallService.deletePOnlinemallByIds(ids));
    }
}
